package com.zhangxiaofanfan.hotcode.fourth.third;


/**
 * <a href="https://leetcode.cn/problems/move-zeroes/description/?envType=study-plan-v2&envId=top-100-liked">移动零</a>
 *
 * @author zhangxiaofanfan
 * @date 2024-05-21 21:21:26
 */
public class HotCode004 {
    public static void main(String[] args) {

    }

    public void moveZeroes(int[] nums) {
        int front = 0, rear = 0;
        for (rear = 0; rear < nums.length; rear++) {
            if (nums[rear] != 0) {
                nums[front++] = nums[rear];
            }
        }
        while (front < nums.length) nums[front++] = 0;
    }
}
